package com.frame.exception

import org.slf4j.Logger
import org.slf4j.LoggerFactory

import javax.ws.rs.core.Response
import javax.ws.rs.ext.ExceptionMapper
import javax.ws.rs.ext.Provider

/**
 * Created by three on 14-7-30.
 */
@Provider
class AllExceptionMapper implements ExceptionMapper<Exception> {

    private Logger log = LoggerFactory.getLogger(AllExceptionMapper.class);

    @Override
    Response toResponse(Exception exception) {
        log.info("系统发生严重异常", exception);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
                entity("系统发生严重错误，请联系管理员").
                type("text/plain").
                build();
    }
}
